package com.hpp.service.impl;

import java.util.HashMap;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hpp.model.NewsInfo;
import com.hpp.persistence.NewsInfoMapper;
import com.hpp.service.INewsService;
import com.hpp.utils.ConfigUtil;

@Service
public class NewsServiceImpl implements INewsService {
	
	@Autowired
	NewsInfoMapper newsInfoMapper;

	@Override
	public NewsInfo getNewsInfo(HashMap<String, Object> map) {
		return newsInfoMapper.getNewsInfo(map);
	}

	@Override
	public List<NewsInfo> getNewsInfoList(HashMap<String, Object> map) {
		List<NewsInfo> list = newsInfoMapper.getNewsInfoList(map);
		for(NewsInfo ns : list){
			ns.setPath(ConfigUtil.get("url") + ns.getImgPath());
		}
		return list;
	}

	@Override
	public int deleteNewsInfo(HashMap<String, Object> map) {
		return newsInfoMapper.deleteNewsInfo(map);
	}

	@Override
	public int addNewsInfo(NewsInfo info) {
		return newsInfoMapper.insertSelective(info);
	}

	@Override
	public int updateNewsInfo(NewsInfo info) {
		return newsInfoMapper.updateByPrimaryKeySelective(info);
	}
}
